package net.runman.web;

import java.util.Arrays;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import net.runman.common.utils.CaptchaUtils;
import net.runman.core.service.IUsersService;

/**
 * 公共控制器
 * @author L.cm
 * @email: 596392912@qq.com
 * @site: http://www.dreamlu.net
 * @date 2016年11月3日下午8:36:51
 */
@Controller
public class CommonController {

	@Autowired
	private IUsersService usersService;
	
	@GetMapping("test.json")
	@ResponseBody
	public Object test() {
		return usersService.selectBatchIds(Arrays.asList(1L, 2L, 3L, 4L, 794377325996146688L));
	}

	@GetMapping("test.html")
	public Object testHtml() {
		return usersService.selectBatchIds(Arrays.asList(1L, 2L, 3L, 4L, 794377325996146688L));
	}

	/**
	 * 图形验证码
	 * @param request
	 * @param response
	 */
	@GetMapping(value = "captcha.jpg")
	public void captcha(HttpServletRequest request, HttpServletResponse response) {
		CaptchaUtils.generate(request, response);
	}
}
